//
//  SelectControlView.m
//  wedding
//
//  Created by 常宽 on 15/1/27.
//  Copyright (c) 2015年 常宽. All rights reserved.
//

#import "SelectControlView.h"

@interface SelectControlView ()
//@property (nonatomic, retain) UIButton *come;       //前进
//@property (nonatomic, retain) UIButton *back;       //后退
//@property (nonatomic, retain) UIButton *collection; //收藏
//@property (nonatomic, retain) UIButton *share;      //分享
@end

@implementation SelectControlView

- (instancetype) initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.come = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        self.come.tag = 220;
        [self addSubview:self.come];
        
        self.back = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        self.back.tag = 221;
        [self addSubview:self.back];
        
        self.collection = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        self.collection.tag = 222;
        [self addSubview:self.collection];
        
        self.share = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        self.share.tag = 223;
        [self addSubview:self.share];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    [self setBackgroundColor:[WebColor white]];
    self.layer.cornerRadius = 5;
    [self.layer setBorderColor:[[WebColor pink] CGColor]];
    [self.layer setBorderWidth:1];
    
    NSArray *array = [NSArray arrayWithObjects:@"后退.png", @"前进.png", @"未收藏.png", @"分享.png", nil];
    
    for (int i = 0; i < 4; i++) {
        UIButton *button = (UIButton *)[self viewWithTag:i + 220];
        button.frame = CGRectMake(5 + (i * (self.frame.size.width / 4 -2)), 5, self.frame.size.width / 4 - 5, self.frame.size.height - 10);
        [button.layer setBorderColor:[[WebColor pink] CGColor]];
        [button.layer setBorderWidth:1];
        [button setBackgroundImage:[UIImage imageNamed:[array objectAtIndex:i]] forState:UIControlStateNormal];
    }
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
